<?php
/*
set_time_limit(0);
$fp = fsockopen("api.t.sina.com.cn",80);
fputs($fp, "GET /statuses/mentions.xml?source=3888029209");
fputs($fp, "Authorization: Basic " . base64_encode("songerzhou@gmail.com:a075513x") );
fpassthru($fp);
*/
//header( "Content-Type:text/html; charset=utf-8" );
//require_once("image.class.php");

header( "Content-type: image/png" );
if ( !( $im = @imagecreatefrompng('back.png') ) )
//if ( !( $im = @imagecreate(440,280) ) )
{
	exit( "Cannot Initialize new GD image stream." );
}
$background_color = imagecolorallocate( $im, 240, 240, 240 );
/*
$i = 0;
for ( ;	$i <= 100;	++$i	)
{
	$point_color = imagecolorallocate( $im, rand( 0, 255 ), rand( 0, 255 ), rand( 0, 255 ) );
	imagesetpixel( $im, rand( 2, 90 ), rand( 2, 24 ), $point_color );
}
$i = 0;
for ( ;	$i <= 3;	++$i	)
{
	$text_color = imagecolorallocate( $im, rand( 0, 255 ), rand( 0, 128 ), rand( 0, 255 ) );
	$x = 2 + $i * 20;
	$y = rand( 2, 10 );
	imagechar( $im, 4, $x, $y, $code[$i], $text_color );
}
*/
$black = imagecolorallocate($im, 0, 0, 0);
$red = imagecolorallocate($im, 255, 0, 0);

imagettftext($im, 20, 0, 25, 30, $red, "simhei.ttf", '2010年11月21日');
imagettftext($im, 14, 0, 215, 30, $black, "simhei.ttf", '农历 庚寅年  生肖 虎');

$font_size = 16;
$font = "SIMLI.TTF";
$start_x = 25;
$start_y = 60;
$step_y = 30;

imagettftext($im, $font_size, 0, $start_x, $start_y, $black, $font, '公  历：');
imagettftext($im, $font_size, 0, $start_x, $start_y + $step_y, $black, $font, '农  历：');
imagettftext($im, $font_size, 0, $start_x, $start_y + $step_y*2, $black, $font, '节  日：');
imagettftext($im, $font_size, 0, $start_x, $start_y + $step_y*3, $black, $font, '节  气：');
imagettftext($im, $font_size, 0, $start_x, $start_y + $step_y*4, $black, $font, '干  支：');
imagettftext($im, $font_size, 0, $start_x, $start_y + $step_y*5, $black, $font, '二十八宿：');
imagettftext($im, $font_size, 0, $start_x, $start_y + $step_y*6, $black, $font, '甲子纳音：');

$font_size = 14;
$font = "simsun.ttc";
$start_x = 135;
$start_y = 61;
$step_y = 30;
imagettftext($im, $font_size, 0, $start_x, $start_y, $black, $font, '2010年11月21日 星期六 金牛座');
imagettftext($im, $font_size, 0, $start_x, $start_y + $step_y, $black, $font, '牛年三月廿九日');
imagettftext($im, $font_size, 0, $start_x, $start_y + $step_y*2, $black, $font, '国际劳动节');
imagettftext($im, $font_size, 0, $start_x, $start_y + $step_y*3, $black, $font, '');
imagettftext($im, $font_size, 0, $start_x, $start_y + $step_y*4, $black, $font, '辛丑年 壬辰月 丁卯日 辛亥时');
imagettftext($im, $font_size, 0, $start_x, $start_y + $step_y*5, $black, $font, '心');
imagettftext($im, $font_size, 0, $start_x, $start_y + $step_y*6, $black, $font, '炉中火');

//imagestring($im, 0, 100, 100, 'hello world', $red);
imagepng( $im );
imagedestroy( $im );

/*
require_once("config.inc.php");
require_once("weibo.class.php");
set_time_limit(0);
$wb = new weibo(APP_KEY, SECRET_KEY);
$wb->setUser( "songerzhou@gmail.com" , "a075513x" );
$testpic = '/usr/local/www/wb/data/test.png';
if(file_exists($testpic))
	print_r($wb->upload('test', file_get_contents($testpic)));
else 
	echo 'test.png not exist';
*/

//system('/usr/local/php5/bin/php -f /usr/local/www/wb/handle_request.php');
//exec('/usr/local/php5/bin/php -f /usr/local/www/wb/handle_request.php');
//passthru ('dir');
//echo `dir`;
?>